package example5;

//461. 汉明距离
public class LeetCode461 {
    public static void main(String[] args) {
        System.out.println(new Solution461_1().hammingDistance(1,4));
    }
}

class Solution461_2 {
    public int hammingDistance(int x, int y) {
        return Integer.bitCount(x ^ y);
    }
}

class Solution461_1 {
    public int hammingDistance(int x, int y) {
        int count = 0;
        while(x != 0 || y != 0){
            if(x % 2 != y % 2){
                count++;
            }
            x /= 2;
            y /= 2;
        }
        return count;
    }
}
